package com.xmall.order.utils;

import java.math.BigDecimal;
import java.math.RoundingMode;

/**
 * 金额计算工具类
 */
public class AmountUtils {

    /**
     * sku金额
     */
    public static BigDecimal skuAmount(BigDecimal price, Integer quantity) {
        return price.multiply(BigDecimal.valueOf(quantity)).setScale(2, RoundingMode.HALF_UP);
    }

    /**
     * 保持两位小数
     */
    public static String scaleAmount(BigDecimal amount) {
        return amount.setScale(2, RoundingMode.HALF_UP).toString();
    }
}
